//创建载具和建筑
params ["_type", "_pos", "_dir"];

if !(_type in asu_simple) exitWith{objNull};


private _z = (_pos select 2) + 0.25;
//systemChat str _z;



//设置碉堡方向
if(_type == "Land_Bunker_01_tall_F") then
{
	_dir = _dir + 180;
};



//
_pos = _pos getPos [1, _dir];

private _pos_temp = [
_pos select 0,
_pos select 1,
_z
];




private _veh = createVehicle [_type, [0,0,0] , [], 0, "NONE"];
_veh setDir _dir;
_veh setVehiclePosition [_pos_temp, [], 0, "CAN_COLLIDE"];
_veh enableDynamicSimulation true;

//平物体 向上
if(_type == "ShootingPos_F") then
{
	_veh setVectorUp [0,0,1];
};

//掩体
if(_type == "Land_SandbagBarricade_01_hole_F") then
{
	_veh setVariable["res_num", 10, true];
};

//碉堡
if(_type == "Land_Bunker_01_tall_F") then
{
	_veh setVariable["res_num", 200, true];
};

//脚手架
if(_type == "Land_Scaffolding_F") then
{
	_veh setVariable["res_num", 20, true];
};

//集装箱
if(_type == "Land_Cargo20_military_green_F") then
{
	_veh setVariable["res_num", 50, true];
};

//货架
if(_type == "Truck_01_Rack_F") then
{
	_veh setVariable["res_num", 30, true];
};



//武器箱
if(_type == "Box_Syndicate_Wps_F") then
{
	clearItemCargoGlobal _veh;
	clearWeaponCargoGlobal _veh;
	clearMagazineCargoGlobal _veh;
	clearBackpackCargoGlobal _veh;
	_veh setVariable ["as_pickup", true, true];
	
	//武器箱有东西，被击中有概率爆炸
	_veh addEventHandler ["Hit", {
		params ["_unit", "_source", "_damage", "_instigator"];
		//systemChat str _instigator;
		if(_damage > 0.10
		&& {!isNull _instigator}
		&& {random 100 < (count (magazineCargo _unit) * 5)}) then{//每个弹夹增加%5的爆炸几率
			_scriptedCharge = "Bo_GBU12_LGB_MI10" createVehicle (getPos _unit);
			_scriptedCharge setDamage 1;
		};
	}];
};


_veh

